<!--
 * @Author: 卡卡 1071780426@qq.com
 * @Date: 2022-11-02 13:13:25
 * @LastEditors: 贺楠 1071780426@qq.com
 * @LastEditTime: 2024-11-20 16:04:40
 * @FilePath: \backstage - 副本\src\views\aa.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div>

        <el-button type="primary" @click="clickUpload" size="mini">上传文件</el-button>
        <upload :dialogUpload="dialogUpload" @closes="closeDialog" fileType="1" folderid="file99" @upFileList="getFile">
        </upload>
        <el-button type="primary" @click="clickUpload1" size="mini">上传照片</el-button>
        <uploads :dialogUpload="dialogUpload1" @closes="closeDialog" fileType="0" folderid="file88"
            @upFileList="getFile"></uploads>
            <input type="file" @change="onVideoChange" accept="video/*" />
      <button v-if="video" @click="uploadVideo">上传视频</button>



    </div>

</template>
 
<script>
import uploads from "../../components/public/el-upload.vue"

import { upload } from "@/api/request.js";


export default {
    components: {

        uploads,

    },
    data() {
        return {
            dialogUpload: false,
            dialogUpload1: false,
            video: null,
        userInfo:{},
        enclosureImg: {},

        };
    },

    watch: {

    },
    methods: {
        onVideoChange(e) {
        this.video = e.target.files[0];
        console.log(this.video);
      },
        async uploadVideo() {
          this.userInfo = JSON.parse(sessionStorage.getItem("GxBack-userInfo"));
      //   const formData = new FormData();
  
      //   formData.append("file", this.video); //将file属性添加到formData里
      //   formData.append("folderid", this.folderid); //将file属性添加到formData里
      //   formData.append("userId", this.userInfo.userId); //将file属性添加到formData里
      //   formData.append("userName", this.userInfo.realName); //将file属性添加到formData里
      //   await this.$http(
      //     "http://1.14.103.201:8300/IOTManagement/App/upload/uploadFile.do",
          
      //     {
      //         headers: {
      //         "Content-Type": "multipart/form-data",
      //       },
      //       method: 'post',
      //     }
      //   ).then((res) => {
      //  console.log(res);
      //   });
  
  
  
      this.enclosureImg = new FormData(); //new一个formData事件
        this.enclosureImg.append("file", this.video); //将file属性添加到formData里
        this.enclosureImg.append("folderid", 'hhhhhhh'); //将file属性添加到formData里
        this.enclosureImg.append("userId", this.userInfo.userId); //将file属性添加到formData里
        this.enclosureImg.append("userName", this.userInfo.realName); //将file属性添加到formData里
     
        upload(this.enclosureImg).then((i) => {
          console.log(i);
          // i[0]["name"] = res.name;
          // i[0]["url"] = res.url;
  
          // this.fileList.push(i[0]);
        });
     
     
      },
        closeDialog() {
            this.dialogUpload = false
        },
        clickUpload() {
            this.dialogUpload = true
        },
        clickUpload1() {
            this.dialogUpload1 = true
        },
        getFile(val) {
            console.log(val);
        },

    }
}
</script>
 
<style lang="less" scoped>

</style>



